//////////////////////////////////////////////////////////////////////////
// FileName:IBaseSingle.cs
// CreateBy:DragonXiong
// CreateDate:2009-10-19
// Description:
//		Class IBaseSingle, for all single table reference
//      
// Modify Log:
//	
// Copyright:ASL
/////////////////////////////////////////////////////////////////////////
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

namespace Auto.Data.BusMan.IDAL
{
    /// <summary>
    /// Interface IBaseSingle
    /// </summary>
    public interface IBaseSingle<T>
    {
        #region --New--
        /// <summary>
        /// Get Model
        /// </summary>
        /// <param name="key">key of Table</param>
        T GetModel(params object[] key);
        #endregion --New--


        #region  --Operate--
        /// <summary>
        /// Is Exists Or Not
        /// </summary>
        /// <param name="key">key of Table</param>
        bool Exists(params object[] key);
        #endregion --Operate--

        #region --SQL--
        /// <summary>
        /// Add Record
        /// </summary>
        /// <param name="model">Model Of Type T</param>
        void Add(T model);
        /// <summary>
        ///  Update One Record
        /// </summary>
        ///  <param name="model">Model Of Type T</param>
        void Update(T model);
        /// <summary>
        /// Delete One Record
        /// </summary>
        /// <param name="key">key of Table</param>
        void Delete(params object[] key);
        #endregion --SQL--

        #region --GetData--
        /// <summary>
        /// Get Data By Primary Key
        /// </summary>
        /// <param name="key">key of Table</param>
        /// <returns>DataTable</returns>
        DataTable GetDataByKeyValue(params object[] key);
        /// <summary>
        /// Get Data List
        /// </summary>
        /// <param name="strWhere">Format: colname1='?' and(or) colname2='?'...</param>
        DataTable GetList(string strWhere);
        /// <summary>
        /// Get Top Rows Record
        /// </summary>
        /// <param name="top">top rows</param>
        /// <param name="strWhere">Format: colname1='?' and(or) colname2='?'...</param>
        /// <param name="fieldOrder">order by field;format: colname1,colname2;</param>
        DataTable GetList(int top, string strWhere, string fieldOrder);

        /// <summary>
        /// Convert Table to Model List<T>
        /// </summary>
        /// <param name="dt">DataTable</param>
        /// <returns>List<T></returns>
        List<T> DataTableToList(DataTable dt);
        /// <summary>
        /// Get Data List By Page
        /// </summary>
        /// <param name="PageSize">Page Size</param>
        /// <param name="PageIndex">Page Index</param>
        /// <param name="strWhere">Format: colname1='?' and(or) colname2='?'...</param>
        /// <returns>DataTable</returns>
        DataTable GetListByPage(int pageSize, int pageIndex, string strWhere);
        #endregion--GetData--
    }
}
